﻿namespace Magiq.Support {
  public static class StringExtensions {
    public static string From(this string text, string start) {
      var index = text.IndexOf(start);
      return index == -1 ? string.Empty : text.Substring(index + start.Length);
    }

    public static string Until(this string text, params string[] ends) {
      var value = text;
      foreach (var end in ends) {
        var index = text.IndexOf(end);
        if (index <= -1) continue;

        var tryValue = text.Substring(0, index);
        if (tryValue.Length < value.Length)
          value = tryValue;
      }
      return value;
    }

    public static string Remove(this string text, string textToRemove) {
      return text.Replace(textToRemove, string.Empty);
    }
  }
}